package com.java.androidmarket.config;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * description:
 * author:张腾
 * date:2021-05-30
 */

@Component
public class RedissonConfig {

    @Value("${redisson.address}")
    private String address;

    @Bean
    public RedissonClient redissonClient(){

        Config config = new Config();
        config.useSingleServer()
                .setAddress(address)
                .setReconnectionTimeout(10000)
                .setRetryInterval(5000)
                .setTimeout(0)
                .setConnectTimeout(10000);

        return Redisson.create(config);
    }

}
